USE [texchange_db]
GO

/****** Object:  UserDefinedFunction [dbo].[Fn_GetLink]    Script Date: 05/29/2011 19:56:11 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE FUNCTION [dbo].[Fn_GetLink] 
(	
	-- Add the parameters for the function here
	@id  bigint=0
)
RETURNS TABLE 
AS
RETURN 
(
	-- Add the SELECT statement with parameter references here
	SELECT [Links].[id], [Links].[link], [Links].[language_id], [Links].[link_text], 
	[Links].[isActive],[Links].[parent_id], utype.link_text as parent_text from [Links]
	LEFT JOIN [Links] as utype on utype.id=Links.parent_id
	 WHERE Links.id=@id
)

GO


